<template>
  <div>
    <van-sticky>
      <van-nav-bar title="动态">
        <template #right>
          <van-icon name="edit" size="20" @click="edit" />
        </template>
      </van-nav-bar>
    </van-sticky>
    <van-pull-refresh
      v-model="isLoading"
      success-text="刷新成功"
      @refresh="onRefresh"
    >
      <div v-for="item in dyInfo" :key="item.index" v-lazy="item">
        <dycard
          :userimage="item.user_face"
          :username="item.user_name"
          :content="item.content"
          :time="$moment(parseInt(item.create_time)).format('YYYY-MM-DD HH:mm')"
          :dy_id="item.dy_id"
          :forwarded="item.forwarded"
          :forward_dy_id="item.forward_dy_id"
          :good="item.good"
        ></dycard>
      </div>
    </van-pull-refresh>
  </div>
</template>

<script>
import axios from "axios";
import flvjs from "flv.js/dist/flv.min.js";
import qs from "../../node_modules/qs";
import dycard from "../components/dyCard";
import { Toast } from "vant";
export default {
  props: [],
  components: {
    dycard,
  },
  data() {
    return {
      dyInfo: "",
      isLoading: false,
      activeName: "1",
    };
  },
  created() {
    this.getAll();
    // this.getInfo()
    // this.more()
  },
  methods: {
    getAll() {
      axios.get("http://localhost:8888/dynamic/findAll").then((res) => {
        this.dyInfo = res.data;
        console.log(this.dyInfo);
      });
    },

    edit() {
      this.$router.push({ name: "writeDy" });
    },
    onRefresh() {
      this.getAll();
      this.isLoading = false;
      // Toast('刷新成功')
    },
  },
};
</script>

<style>
.dynamicCard {
  margin: 10px;
}
</style>
